package main

import (
	"net/http"
	
	"go.uber.org/zap"
)

// 极致的性能
var logger *zap.Logger

// 易用与性能相互权衡
var sugarLogger *zap.SugaredLogger

func main() {
	initLogger()
	defer sugarLogger.Sync()
	
	simpleHttpGet("https://www.baidu.com")
	
}

func simpleHttpGet(url string) {
	sugarLogger.Debug("Trying to hit GET request for %s", url)
	res, err := http.Get(url)
	if err != nil {
		sugarLogger.Error("Error fetching Url %s : Err = %v", url, err)
	} else {
		sugarLogger.Info("Success! statusCode = %s for url %s", res.StatusCode, url)
	}
}

func initLogger() {
	logger, _ = zap.NewDevelopment()
	sugarLogger = logger.Sugar()
}


